# 绝对引用
from __future__ import absolute_import, unicode_literals

from celery import shared_task
from ronglian_sms_sdk import SmsSDK
import json

# app = Celery('tasks', broker='redis://localhost/1')
# 短信
ACCOUNT_SID = '8aaf0708762cb1cf01766e6de66619af'
AUTH_TOKEN = '487f6380d65144dd923fab2109a40a6f'
APP_ID = '8aaf0708762cb1cf01766e6de73d19b6'


@shared_task
def send_message(phone, code):
    sdk = SmsSDK(ACCOUNT_SID, AUTH_TOKEN, APP_ID)
    resp = sdk.sendMessage('1', phone, (code, 5))
    ser = json.loads(resp)
    if ser['statusCode'] == '000000':
        return True
    else:
        return False


